Hello, and sorry again...I don't like to keep asking help, but I'm not seeing what is wrong.
-I- DXL: execution halted
/*===========================================================================================
Date: ??/08/2011
Bruna Aquino
==========================================================================================*/
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===
////////////// Variables //////////////
*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===*/
Project pSys = project "/EMB550_04_Systems"
Object obj = current
Module m
int iQC1, iQC2
string currentQC1, currentQC2
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===
/////////////// Interface Items ////////////////
*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===*/
DB verEvidenceBox = create("Synoptics Completeness Validation Checklist - Rev (-)")
DBE tagField, statusField, authorField
DBE selectChoiceQC1, selectChoiceQC2
DBE richTextReq, richTextApp, textMultiLine, selectHelp
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===
/////////////// Answer Types ////////////////
*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===*/
string options[] = {"YES", "NO", "Not Evaluated"}
string errMess = "Error creating type."
AttrType answerType = find(current Module, "Answer")
if (null answerType) answerType = create ("Answer", options, errMess)
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===
/////////////// Functions //////////////
*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===*/
void deleteAttrDef(string s){
AttrDef ad = find(current Module, s)
if (null ad) // print "Attr Def '" s "' does not exist.\n"
else delete(ad)
}
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/
void deleteAttrType(string s){
string err = ""
AttrType at = find(current Module, s)
if (null at) // print "Attr Type '" s "' does not exist.\n"
else delete(at, err)
}
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/
// Status field will always reflect the actual answers for all questions
void setStatus(Module m){
Project pSys = project "/EMB550_04_Systems"
bool ValInd, NotEvalInd, NotValInd
ValInd = false
NotEvalInd = false
NotValInd = false
for m in pSys do {
if (isEdit(m)){
if (m."Validation Q1CSYS" ""=="YES" && m."Validation Q2CSYS" ""=="YES") {
ValInd = true
}
else {
if (m."Validation Q1CSYS" ""=="Not Evaluated" && m."Validation Q2CSYS" ""=="Not Evaluated") {
NotEvalInd = true
}else NotValInd = true
}
if (NotValInd) {
m."Completeness Validation Status" = "Not Valid"
} else if (NotEvalInd){
m."Completeness Validation Status" = "Not Validated"
} else m."Completeness Validation Status" = "Valid" ""
}
if (!isEdit(m)) then
infoBox "Open module as Shareable or Exclusive Edit."; continue
}
}
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/
// Return the last author of the current object
string lastObjectTextModifier(){
History h
string lastAuthor = ""
for h in current Object do {
HistoryType ht = h.type
if (ht == modifyObject && h.attrName == "Object Text") lastAuthor = h.author
}
return lastAuthor
}
void updateVariables(Module m) {
for m in pSys do {
string currentQC1 = m."Validation Q1CSYS" ""
string currentQC2 = m."Validation Q2CSYS" ""
for iQC1 in 0:3 by 1 do {
if (currentQC1 == answerType.strings[iQC1]) { break }
iQC1++
}
for iQC2 in 0:3 by 1 do {
if (currentQC2 == answerType.strings[iQC2]) { break }
iQC2++
}
set(selectChoiceQC1,iQC1)
set(selectChoiceQC2,iQC2)
set(textMultiLine, m."Completeness Validation Comments" "")
setStatus(m)
refresh m
}
}
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/
bool notExistAttribute(string aName){
AttrDef ad = find(current Module, aName)
if (null ad) return true
else return false
}
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/
// Save all validation questions and Validation Comments
void saveObjects(Module m){
User u = find() // returns current user login.
string userLogin = u.name
string aux = ""
int i
bool wasModified = false
if (get(selectChoiceQC1) =="NO" || get(selectChoiceQC1)=="NO" ) {
if (get(textMultiLine) == "") {
warningBox("Add comments that describe why the requirement is not valid or the data entered will not be saved.\nThis will help author to correct the requirement.")
return
}
}
if(canModify(m)){
aux = get(selectChoiceQC1)
if(m."Validation Q1CSYS" "" != aux) {
m."Validation Q1CSYS" = aux
wasModified = true
}
aux = get(selectChoiceQC2)
if(m."Validation Q2CSYS" "" != aux) {
m."Validation Q2CSYS" = aux
wasModified = true
}
aux = get(textMultiLine)
if(m."Completeness Validation Comments" "" != aux) {
m."Completeness Validation Comments" = get(textMultiLine)
wasModified = true
}
// Save checker
if(wasModified){ // Saves Checker just if something has changed.
User u = find() // returns current user login.
string uName = u.name
obj."Completeness Checker" = uName// just save if is requirement.
}
}
else infoBox "Cannot modify current object."
}
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/
void saveReport(DB calledFrom){
saveObjects(m) // Saves all validation questions and Validation Comments.
save(m)
refresh (m)
}
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/
void closeBox(DB calledFrom){
if(unsaved(Module m)){
string buttons[] = {"Yes", "No"}
int answer = messageBox("To save the validation, save current module. \nSave current module?", buttons, msgWarning)
if(buttons[answer] == "Yes") {
saveObjects(m) // Saves all validation questions and Validation Comments.
save(m)
refresh (m)
}
}
hide calledFrom
}
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/
bool notExistAttribute(string attrName){
AttrDef ad = find(current Module, attrName)
if (null ad) return true
else {
return false
}
}
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===
////////////////// Main Program //////////////////
*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===*/
// Start to buid GUI
saveButton = apply(verEvidenceBox, "&Save Module", saveReport)
close(verEvidenceBox, true, closeBox)
// Questions
selectChoiceQC1 = choice(verEvidenceBox, "Q1: ?", options, 1, 13,false)
selectChoiceQC2 = choice(verEvidenceBox, "Q2: ?", options, 1, 13,false)
statusField = field(verEvidenceBox, "Completeness Validation Status", "", 13, true)
textMultiLine = text(verEvidenceBox, "Completeness Validation Comments","", 30, 60, false )
realize verEvidenceBox
updateVariables(m)
show verEvidenceBox
Bruwbruw - Fri Aug 10 09:02:00 EDT 2012 |
Re: Can't see the error
I think if you remove "m" as a call parameter to updateVariables() it will work. Function "updateVariables(Module m)" accepts "m", but immediately does this
I see that...
Thus, of course, it's not yet defined. I used to make this mistake quite a lot so I adopted conventions that:
There are indeed some very sharp folks who can remember and handle sloppy names, but the rest of us need more discipline. And the sharp folks need to accept that dull folks are going to read their code eventually. -Louie Your indentation bytes. Thank goodness your clean short well-defined functions mitigate that rather serious flaw. Consider turning on "show tab characters" and "show matching braces" in your editor. |
Re: Can't see the error llandale - Fri Aug 10 10:50:52 EDT 2012
I think if you remove "m" as a call parameter to updateVariables() it will work. Function "updateVariables(Module m)" accepts "m", but immediately does this
I see that...
Thus, of course, it's not yet defined. I used to make this mistake quite a lot so I adopted conventions that:
There are indeed some very sharp folks who can remember and handle sloppy names, but the rest of us need more discipline. And the sharp folks need to accept that dull folks are going to read their code eventually. -Louie Your indentation bytes. Thank goodness your clean short well-defined functions mitigate that rather serious flaw. Consider turning on "show tab characters" and "show matching braces" in your editor.
Hi, I have spend some days without work in my own code, plus my own doubt on how to proceed , take those two and its never a good combination...
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===
////////////// Variables //////////////
*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===*/
Project pSys = project "/EMB550_04_Systems"
Object obj = current
Module m
Item itemRef
Skip modNameList = create
string parentPrj, parentFolder, moduleName, fullModName
int count = 0
int iQC1, iQC2
string currentQC1, currentQC2
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===
/////////////// Interface Items ////////////////
*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===*/
DB verEvidenceBox = create("Synoptics Completeness Validation Checklist - Rev (-)")
DBE tagField, statusField, authorField
DBE selectChoiceQC1, selectChoiceQC2
DBE richTextReq, richTextApp, textMultiLine, selectHelp
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===
/////////////// Answer Types ////////////////
*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===*/
string options[] = {"YES", "NO", "Not Evaluated"}
string errMess = "Error creating type."
AttrType answerType = find(current Module, "Answer")
if (null answerType) answerType = create ("Answer", options, errMess)
// Projects that starts with '_' are not requirements.
bool matchPrj(string prjName){
if(matches("(_)", prjName)) return false
return true
}
// All formal modules inside SIR and SRS folders.
bool matchType(string modName){
if ((matches("(SRS)", modName)) || (matches("(SIR)", modName))){
return true
}
return false
}
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===
/////////////// Functions //////////////
*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===*/
void deleteAttrDef(string s){
AttrDef ad = find(current Module, s)
if (null ad) // print "Attr Def '" s "' does not exist.\n"
else delete(ad)
}
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/
void deleteAttrType(string s){
string err = ""
AttrType at = find(current Module, s)
if (null at) // print "Attr Type '" s "' does not exist.\n"
else delete(at, err)
}
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/
// Status field will always reflect the actual answers for all questions
void setStatus(Module &m){
string fullModName, str = ""
bool ValInd, NotEvalInd, NotValInd
ValInd = false
NotEvalInd = false
NotValInd = false
fullModName = fullName(m)
if (m."Validation Q1CSYS" ""=="YES" && m."Validation Q2CSYS" ""=="YES") {
ValInd = true
}
else {
if (m."Validation Q1CSYS" ""=="Not Evaluated" && m."Validation Q2CSYS" ""=="Not Evaluated") {
NotEvalInd = true
}else NotValInd = true
}
if (NotValInd) {
m."Completeness Validation Status" = "Not Valid"
} else if (NotEvalInd){
m."Completeness Validation Status" = "Not Validated"
}
else m."Completeness Validation Status" = "Valid"
}
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/
void updateVariables(Module &m) {
string fullModName
fullModName = fullName(m)
string currentQC1 = m."Validation Q1CSYS" ""
string currentQC2 = m."Validation Q2CSYS" ""
for iQC1 in 0:3 by 1 do {
if (currentQC1 == answerType.strings[iQC1]) { break }
iQC1++
}
for iQC2 in 0:3 by 1 do {
if (currentQC2 == answerType.strings[iQC2]) { break }
iQC2++
}
set(selectChoiceQC1,iQC1)
set(selectChoiceQC2,iQC2)
set(textMultiLine, m."Completeness Validation Comments" "")
setStatus(m)
refresh (m)
}
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/
bool notExistAttribute(string aName){
AttrDef ad = find(current Module, aName)
if (null ad) return true
else return false
}
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/
// Save all validation questions and Validation Comments
void saveObjects(Module &m){
string fullModName
fullModName = fullName(m)
User u = find() // returns current user login.
string userLogin = u.name
string aux = ""
int i
bool wasModified = false
if (get(selectChoiceQC1) =="NO" || get(selectChoiceQC2)=="NO" ) {
return
}
if(canModify(m)){
aux = get(selectChoiceQC1)
if(m."Validation Q1CSYS" "" != aux) {
m."Validation Q1CSYS" = aux
wasModified = true
}
aux = get(selectChoiceQC2)
if(m."Validation Q2CSYS" "" != aux) {
m."Validation Q2CSYS" = aux
wasModified = true
}
aux = get(textMultiLine)
if(m."Completeness Validation Comments" "" != aux) {
m."Completeness Validation Comments" = get(textMultiLine)
wasModified = true
}
// Save checker
if(wasModified){ // Saves Checker just if something has changed.
User u = find() // returns current user login.
string uName = u.name
obj."Completeness Checker" = uName// just save if is requirement.
}
}
else infoBox "Cannot modify current object."
}
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/
void saveReport(DB calledFrom){
saveObjects(m) // Saves all validation questions and Validation Comments.
save(m)
refresh (m)
}
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/
void closeBox(DB calledFrom){
if(unsaved(current Module)){
string buttons[] = {"Yes", "No"}
int answer = messageBox("To save the validation, save current module. \nSave current module?", buttons, msgWarning)
if(buttons[answer] == "Yes") {
saveObjects(m) // Saves all validation questions and Validation Comments.
save(m)
refresh (m)
}
}
hide calledFrom
}
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/
bool notExistAttribute(string attrName){
AttrDef ad = find(current Module, attrName)
if (null ad) return true
else {
return false
}
}
This part I'm doing the loop, the ideia is to get the answer I choose and loop throught the opened modules filling the attributes.
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/
for itemRef in pSys do{
if (type(itemRef) "" == "Formal"){ // Look up just formal modules.
moduleName = name(itemRef)
parentPrj = fullName(getParentProject(itemRef))
if(matchPrj(parentPrj)){ // Just for some projects.
parentFolder = fullName(getParentFolder(itemRef))
if(matchType(parentFolder)){ // Just for some projects.
if(canModify(itemRef)){
put(modNameList, name(itemRef), fullName(itemRef))
count++
}
else{
print moduleName ": Cannot modify.\n"
}
}
}
}
}
This part is where the I'm having dificulties, I know how to open the modules, but I don't want to open it, I wanna to fill the ones already opened
for fullModName in modNameList do{
m = edit(fullModName, false)
if(canModify(m)){
setStatus(m)
updateVariables(m)
save(m)
close(m)
}
}
Now the end of the dxl
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===
////////////////// Main Program //////////////////
*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===*/
// Start to buid GUI
saveButton = apply(verEvidenceBox, "&Save Module", saveReport)
close(verEvidenceBox, true, closeBox)
// Questions
selectChoiceQC1 = choice(verEvidenceBox, "Q1: ?", options, 1, 13,false)
selectChoiceQC2 = choice(verEvidenceBox, "Q2: ?", options, 1, 13,false)
statusField = field(verEvidenceBox, "Completeness Validation Status", "", 13, true)
textMultiLine = text(verEvidenceBox, "Completeness Validation Comments","", 30, 60, false )
realize verEvidenceBox
updateVariables(m)
show verEvidenceBox
|
Re: Can't see the error Bruwbruw - Wed Aug 15 08:26:32 EDT 2012
Hi, I have spend some days without work in my own code, plus my own doubt on how to proceed , take those two and its never a good combination...
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===
////////////// Variables //////////////
*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===*/
Project pSys = project "/EMB550_04_Systems"
Object obj = current
Module m
Item itemRef
Skip modNameList = create
string parentPrj, parentFolder, moduleName, fullModName
int count = 0
int iQC1, iQC2
string currentQC1, currentQC2
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===
/////////////// Interface Items ////////////////
*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===*/
DB verEvidenceBox = create("Synoptics Completeness Validation Checklist - Rev (-)")
DBE tagField, statusField, authorField
DBE selectChoiceQC1, selectChoiceQC2
DBE richTextReq, richTextApp, textMultiLine, selectHelp
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===
/////////////// Answer Types ////////////////
*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===*/
string options[] = {"YES", "NO", "Not Evaluated"}
string errMess = "Error creating type."
AttrType answerType = find(current Module, "Answer")
if (null answerType) answerType = create ("Answer", options, errMess)
// Projects that starts with '_' are not requirements.
bool matchPrj(string prjName){
if(matches("(_)", prjName)) return false
return true
}
// All formal modules inside SIR and SRS folders.
bool matchType(string modName){
if ((matches("(SRS)", modName)) || (matches("(SIR)", modName))){
return true
}
return false
}
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===
/////////////// Functions //////////////
*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===*/
void deleteAttrDef(string s){
AttrDef ad = find(current Module, s)
if (null ad) // print "Attr Def '" s "' does not exist.\n"
else delete(ad)
}
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/
void deleteAttrType(string s){
string err = ""
AttrType at = find(current Module, s)
if (null at) // print "Attr Type '" s "' does not exist.\n"
else delete(at, err)
}
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/
// Status field will always reflect the actual answers for all questions
void setStatus(Module &m){
string fullModName, str = ""
bool ValInd, NotEvalInd, NotValInd
ValInd = false
NotEvalInd = false
NotValInd = false
fullModName = fullName(m)
if (m."Validation Q1CSYS" ""=="YES" && m."Validation Q2CSYS" ""=="YES") {
ValInd = true
}
else {
if (m."Validation Q1CSYS" ""=="Not Evaluated" && m."Validation Q2CSYS" ""=="Not Evaluated") {
NotEvalInd = true
}else NotValInd = true
}
if (NotValInd) {
m."Completeness Validation Status" = "Not Valid"
} else if (NotEvalInd){
m."Completeness Validation Status" = "Not Validated"
}
else m."Completeness Validation Status" = "Valid"
}
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/
void updateVariables(Module &m) {
string fullModName
fullModName = fullName(m)
string currentQC1 = m."Validation Q1CSYS" ""
string currentQC2 = m."Validation Q2CSYS" ""
for iQC1 in 0:3 by 1 do {
if (currentQC1 == answerType.strings[iQC1]) { break }
iQC1++
}
for iQC2 in 0:3 by 1 do {
if (currentQC2 == answerType.strings[iQC2]) { break }
iQC2++
}
set(selectChoiceQC1,iQC1)
set(selectChoiceQC2,iQC2)
set(textMultiLine, m."Completeness Validation Comments" "")
setStatus(m)
refresh (m)
}
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/
bool notExistAttribute(string aName){
AttrDef ad = find(current Module, aName)
if (null ad) return true
else return false
}
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/
// Save all validation questions and Validation Comments
void saveObjects(Module &m){
string fullModName
fullModName = fullName(m)
User u = find() // returns current user login.
string userLogin = u.name
string aux = ""
int i
bool wasModified = false
if (get(selectChoiceQC1) =="NO" || get(selectChoiceQC2)=="NO" ) {
return
}
if(canModify(m)){
aux = get(selectChoiceQC1)
if(m."Validation Q1CSYS" "" != aux) {
m."Validation Q1CSYS" = aux
wasModified = true
}
aux = get(selectChoiceQC2)
if(m."Validation Q2CSYS" "" != aux) {
m."Validation Q2CSYS" = aux
wasModified = true
}
aux = get(textMultiLine)
if(m."Completeness Validation Comments" "" != aux) {
m."Completeness Validation Comments" = get(textMultiLine)
wasModified = true
}
// Save checker
if(wasModified){ // Saves Checker just if something has changed.
User u = find() // returns current user login.
string uName = u.name
obj."Completeness Checker" = uName// just save if is requirement.
}
}
else infoBox "Cannot modify current object."
}
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/
void saveReport(DB calledFrom){
saveObjects(m) // Saves all validation questions and Validation Comments.
save(m)
refresh (m)
}
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/
void closeBox(DB calledFrom){
if(unsaved(current Module)){
string buttons[] = {"Yes", "No"}
int answer = messageBox("To save the validation, save current module. \nSave current module?", buttons, msgWarning)
if(buttons[answer] == "Yes") {
saveObjects(m) // Saves all validation questions and Validation Comments.
save(m)
refresh (m)
}
}
hide calledFrom
}
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/
bool notExistAttribute(string attrName){
AttrDef ad = find(current Module, attrName)
if (null ad) return true
else {
return false
}
}
This part I'm doing the loop, the ideia is to get the answer I choose and loop throught the opened modules filling the attributes.
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*====*/
for itemRef in pSys do{
if (type(itemRef) "" == "Formal"){ // Look up just formal modules.
moduleName = name(itemRef)
parentPrj = fullName(getParentProject(itemRef))
if(matchPrj(parentPrj)){ // Just for some projects.
parentFolder = fullName(getParentFolder(itemRef))
if(matchType(parentFolder)){ // Just for some projects.
if(canModify(itemRef)){
put(modNameList, name(itemRef), fullName(itemRef))
count++
}
else{
print moduleName ": Cannot modify.\n"
}
}
}
}
}
This part is where the I'm having dificulties, I know how to open the modules, but I don't want to open it, I wanna to fill the ones already opened
for fullModName in modNameList do{
m = edit(fullModName, false)
if(canModify(m)){
setStatus(m)
updateVariables(m)
save(m)
close(m)
}
}
Now the end of the dxl
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===
////////////////// Main Program //////////////////
*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===*/
// Start to buid GUI
saveButton = apply(verEvidenceBox, "&Save Module", saveReport)
close(verEvidenceBox, true, closeBox)
// Questions
selectChoiceQC1 = choice(verEvidenceBox, "Q1: ?", options, 1, 13,false)
selectChoiceQC2 = choice(verEvidenceBox, "Q2: ?", options, 1, 13,false)
statusField = field(verEvidenceBox, "Completeness Validation Status", "", 13, true)
textMultiLine = text(verEvidenceBox, "Completeness Validation Comments","", 30, 60, false )
realize verEvidenceBox
updateVariables(m)
show verEvidenceBox
What does "doesn't work" mean exactly? I notice that Skip modNameList ..
I think you want to use "for m in project do" to find Modules open in the Project. Looping for all items and using "canModify" doesn't feel right.
I don't see where you are modifying the module; if so "save(m)" doesn't do anything; and you don't need the "edit" command. "m" as global variable doesn't feel right, but I cannot tell exactly. It makes sense if one of your buttons needs to tell another button which open module it last dealt with; but I don't think you do that. If "m" represents the original module the code is run from, then do NOT use "m" in all your functions. -Louie |
Re: Can't see the error llandale - Wed Aug 15 10:42:35 EDT 2012
I think you want to use "for m in project do" to find Modules open in the Project. Looping for all items and using "canModify" doesn't feel right.
I don't see where you are modifying the module; if so "save(m)" doesn't do anything; and you don't need the "edit" command. "m" as global variable doesn't feel right, but I cannot tell exactly. It makes sense if one of your buttons needs to tell another button which open module it last dealt with; but I don't think you do that. If "m" represents the original module the code is run from, then do NOT use "m" in all your functions. -Louie
Sorry, the main problem is that I did not have time to stop and analize the dxl.
/*===================================================================================
Date: ??/08/2011
Bruna Aquino
=========================================================================================*/
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===
////////////// Variables //////////////
*=====*=====*======*======*======*=====*=====*======*======*======*======*=====*=====*===*/
Project pSys = project "/EMB550_04_Systems"
Object obj = current
Module m
string parentPrj, parentFolder, moduleName, fullModName
int count = 0
int iQC1, iQC2
string currentQC1, currentQC2
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===
/////////////// Interface Items ////////////////
*=====*=====*======*======*======*=====*=====*======*======*======*======*=====*=====*===*/
DB verEvidenceBox = create("Synoptics Completeness Validation Checklist - Rev (-)")
DBE tagField, statusField, authorField
DBE selectChoiceQC1, selectChoiceQC2
DBE richTextReq, richTextApp, textMultiLine, selectHelp
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===
/////////////// Answer Types ////////////////
*=====*=====*======*======*======*=====*=====*======*======*======*======*=====*=====*===*/
string options[] = {"YES", "NO", "Not Evaluated"}
string errMess = "Error creating type."
AttrType answerType = find(current Module, "Answer")
if (null answerType) answerType = create ("Answer", options, errMess)
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===
/////////////// Functions //////////////
*=====*=====*======*======*======*=====*=====*======*======*======*======*=====*=====*===*/
void deleteAttrDef(string s){
AttrDef ad = find(current Module, s)
if (null ad) // print "Attr Def '" s "' does not exist.\n"
else delete(ad)
}
/*=====*=====*=====*=====*======*=====*=====*======*======*======*======*=====*=====*====*/
void deleteAttrType(string s){
string err = ""
AttrType at = find(current Module, s)
if (null at) // print "Attr Type '" s "' does not exist.\n"
else delete(at, err)
}
/*=====*=====*=====*=====*======*=====*=====*======*======*======*======*=====*=====*====*/
// Status field will always reflect the actual answers for all questions
void setStatus(){
m = current Module
bool ValInd, NotEvalInd, NotValInd
ValInd = false
NotEvalInd = false
NotValInd = false
if (m."Validation Q1CSYS" ""=="YES" && m."Validation Q2CSYS" ""=="YES") {
ValInd = true
}
else {
if (m."Validation Q1CSYS" ""=="Not Evaluated" && m."Validation Q2CSYS" ""=="Not Evaluated") {
NotEvalInd = true
}else NotValInd = true
}
if (NotValInd) {
m."Completeness Validation Status" = "Not Valid"
} else if (NotEvalInd){
m."Completeness Validation Status" = "Not Validated"
} else m."Completeness Validation Status" = "Valid"
}
/*=====*=====*=====*=====*======*=====*=====*======*======*======*======*=====*=====*====*/
// Return the last author of the current object
string lastObjectTextModifier(){
History h
string lastAuthor = ""
for h in current Object do {
HistoryType ht = h.type
if (ht == modifyObject && h.attrName == "Object Text") lastAuthor = h.author
}
return lastAuthor
}
void updateVariables() {
m = current Module
string currentQC1 = m."Validation Q1CSYS" ""
string currentQC2 = m."Validation Q2CSYS" ""
for iQC1 in 0:3 by 1 do {
if (currentQC1 == answerType.strings[iQC1]) { break }
iQC1++
}
for iQC2 in 0:3 by 1 do {
if (currentQC2 == answerType.strings[iQC2]) { break }
iQC2++
}
set(selectChoiceQC1,iQC1)
set(selectChoiceQC2,iQC2)
set(textMultiLine, m."Completeness Validation Comments" "")
setStatus()
refresh current Module
}
/*=====*======*=====*=====*=====*=====*=====*======*======*======*======*=====*=====*====*/
bool notExistAttribute(string aName){
AttrDef ad = find(current Module, aName)
if (null ad) return true
else return false
}
/*=====*======*=====*=====*=====*=====*=====*======*======*======*======*=====*=====*====*/
// Save all validation questions and Validation Comments
void saveObjects(){
User u = find() // returns current user login.
string userLogin = u.name
string aux = ""
int i
bool wasModified = false
m = current Module
if (get(selectChoiceQC1) =="NO" || get(selectChoiceQC2)=="NO" ) {
return
}
if(canModify(m)){
aux = get(selectChoiceQC1)
if(m."Validation Q1CSYS" "" != aux) {
m."Validation Q1CSYS" = aux
wasModified = true
}
aux = get(selectChoiceQC2)
if(m."Validation Q2CSYS" "" != aux) {
m."Validation Q2CSYS" = aux
wasModified = true
}
aux = get(textMultiLine)
if(m."Completeness Validation Comments" "" != aux) {
m."Completeness Validation Comments" = get(textMultiLine)
wasModified = true
}
// Save checker
if(wasModified){ // Saves Checker just if something has changed.
User u = find() // returns current user login.
string uName = u.name
obj."Completeness Checker" = uName// just save if is requirement.
}
}
else infoBox "Cannot modify current object."
}
/*=====*======*=====*=====*=====*=====*=====*======*======*======*======*=====*=====*====*/
void saveReport(DB calledFrom){
saveObjects() // Saves all validation questions and Validation Comments.
save(current Module)
refresh (current Module)
}
/*=====*=====*=====*=====*======*=====*=====*======*======*======*======*=====*=====*====*/
void closeBox(DB calledFrom){
if(unsaved(current Module)){
string buttons[] = {"Yes", "No"}
int answer = messageBox("To save the validation, save current module. \nSave current module?", buttons, msgWarning)
if(buttons[answer] == "Yes") {
saveObjects() // Saves all validation questions and Validation Comments.
save(current Module)
refresh (current Module)
}
}
hide calledFrom
}
/*=====*=====*=====*=====*=====*=====*=====*======*======*======*======*=====*=====*====*/
bool notExistAttribute(string attrName){
AttrDef ad = find(current Module, attrName)
if (null ad) return true
else {
return false
}
}
/*
//Project pSys = project "/EMB550_04_Systems"
Module m
for m in current Project do{
if (isEdit m)
print m."Name" "\n"
}*/
for m in pSys do{
if (isEdit m){
setStatus()
updateVariables()
saveObjects()
}
}
/*=====*======*=====*======*======*=====*=====*======*======*======*======*=====*=====*===
////////////////// Main Program //////////////////
*=====*======*=====*======*======*=====*=====*======*======*======*======*=====*=====*===*/
// Start to buid GUI
saveButton = apply(verEvidenceBox, "&Save Module", saveReport)
close(verEvidenceBox, true, closeBox)
// Questions
selectChoiceQC1 = choice(verEvidenceBox, "Q1: ?", options, 1, 13,false)
selectChoiceQC2 = choice(verEvidenceBox, "Q2: ?", options, 1, 13,false)
statusField = field(verEvidenceBox, "Completeness Validation Status", "", 13, true)
textMultiLine = text(verEvidenceBox, "Completeness Validation Comments","", 30, 60, false )
realize verEvidenceBox
updateVariables()
show verEvidenceBox
|
Re: Can't see the error Bruwbruw - Tue Aug 21 13:28:00 EDT 2012
Sorry, the main problem is that I did not have time to stop and analize the dxl.
/*===================================================================================
Date: ??/08/2011
Bruna Aquino
=========================================================================================*/
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===
////////////// Variables //////////////
*=====*=====*======*======*======*=====*=====*======*======*======*======*=====*=====*===*/
Project pSys = project "/EMB550_04_Systems"
Object obj = current
Module m
string parentPrj, parentFolder, moduleName, fullModName
int count = 0
int iQC1, iQC2
string currentQC1, currentQC2
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===
/////////////// Interface Items ////////////////
*=====*=====*======*======*======*=====*=====*======*======*======*======*=====*=====*===*/
DB verEvidenceBox = create("Synoptics Completeness Validation Checklist - Rev (-)")
DBE tagField, statusField, authorField
DBE selectChoiceQC1, selectChoiceQC2
DBE richTextReq, richTextApp, textMultiLine, selectHelp
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===
/////////////// Answer Types ////////////////
*=====*=====*======*======*======*=====*=====*======*======*======*======*=====*=====*===*/
string options[] = {"YES", "NO", "Not Evaluated"}
string errMess = "Error creating type."
AttrType answerType = find(current Module, "Answer")
if (null answerType) answerType = create ("Answer", options, errMess)
/*=====*======*======*======*======*=====*=====*======*======*======*======*=====*=====*===
/////////////// Functions //////////////
*=====*=====*======*======*======*=====*=====*======*======*======*======*=====*=====*===*/
void deleteAttrDef(string s){
AttrDef ad = find(current Module, s)
if (null ad) // print "Attr Def '" s "' does not exist.\n"
else delete(ad)
}
/*=====*=====*=====*=====*======*=====*=====*======*======*======*======*=====*=====*====*/
void deleteAttrType(string s){
string err = ""
AttrType at = find(current Module, s)
if (null at) // print "Attr Type '" s "' does not exist.\n"
else delete(at, err)
}
/*=====*=====*=====*=====*======*=====*=====*======*======*======*======*=====*=====*====*/
// Status field will always reflect the actual answers for all questions
void setStatus(){
m = current Module
bool ValInd, NotEvalInd, NotValInd
ValInd = false
NotEvalInd = false
NotValInd = false
if (m."Validation Q1CSYS" ""=="YES" && m."Validation Q2CSYS" ""=="YES") {
ValInd = true
}
else {
if (m."Validation Q1CSYS" ""=="Not Evaluated" && m."Validation Q2CSYS" ""=="Not Evaluated") {
NotEvalInd = true
}else NotValInd = true
}
if (NotValInd) {
m."Completeness Validation Status" = "Not Valid"
} else if (NotEvalInd){
m."Completeness Validation Status" = "Not Validated"
} else m."Completeness Validation Status" = "Valid"
}
/*=====*=====*=====*=====*======*=====*=====*======*======*======*======*=====*=====*====*/
// Return the last author of the current object
string lastObjectTextModifier(){
History h
string lastAuthor = ""
for h in current Object do {
HistoryType ht = h.type
if (ht == modifyObject && h.attrName == "Object Text") lastAuthor = h.author
}
return lastAuthor
}
void updateVariables() {
m = current Module
string currentQC1 = m."Validation Q1CSYS" ""
string currentQC2 = m."Validation Q2CSYS" ""
for iQC1 in 0:3 by 1 do {
if (currentQC1 == answerType.strings[iQC1]) { break }
iQC1++
}
for iQC2 in 0:3 by 1 do {
if (currentQC2 == answerType.strings[iQC2]) { break }
iQC2++
}
set(selectChoiceQC1,iQC1)
set(selectChoiceQC2,iQC2)
set(textMultiLine, m."Completeness Validation Comments" "")
setStatus()
refresh current Module
}
/*=====*======*=====*=====*=====*=====*=====*======*======*======*======*=====*=====*====*/
bool notExistAttribute(string aName){
AttrDef ad = find(current Module, aName)
if (null ad) return true
else return false
}
/*=====*======*=====*=====*=====*=====*=====*======*======*======*======*=====*=====*====*/
// Save all validation questions and Validation Comments
void saveObjects(){
User u = find() // returns current user login.
string userLogin = u.name
string aux = ""
int i
bool wasModified = false
m = current Module
if (get(selectChoiceQC1) =="NO" || get(selectChoiceQC2)=="NO" ) {
return
}
if(canModify(m)){
aux = get(selectChoiceQC1)
if(m."Validation Q1CSYS" "" != aux) {
m."Validation Q1CSYS" = aux
wasModified = true
}
aux = get(selectChoiceQC2)
if(m."Validation Q2CSYS" "" != aux) {
m."Validation Q2CSYS" = aux
wasModified = true
}
aux = get(textMultiLine)
if(m."Completeness Validation Comments" "" != aux) {
m."Completeness Validation Comments" = get(textMultiLine)
wasModified = true
}
// Save checker
if(wasModified){ // Saves Checker just if something has changed.
User u = find() // returns current user login.
string uName = u.name
obj."Completeness Checker" = uName// just save if is requirement.
}
}
else infoBox "Cannot modify current object."
}
/*=====*======*=====*=====*=====*=====*=====*======*======*======*======*=====*=====*====*/
void saveReport(DB calledFrom){
saveObjects() // Saves all validation questions and Validation Comments.
save(current Module)
refresh (current Module)
}
/*=====*=====*=====*=====*======*=====*=====*======*======*======*======*=====*=====*====*/
void closeBox(DB calledFrom){
if(unsaved(current Module)){
string buttons[] = {"Yes", "No"}
int answer = messageBox("To save the validation, save current module. \nSave current module?", buttons, msgWarning)
if(buttons[answer] == "Yes") {
saveObjects() // Saves all validation questions and Validation Comments.
save(current Module)
refresh (current Module)
}
}
hide calledFrom
}
/*=====*=====*=====*=====*=====*=====*=====*======*======*======*======*=====*=====*====*/
bool notExistAttribute(string attrName){
AttrDef ad = find(current Module, attrName)
if (null ad) return true
else {
return false
}
}
/*
//Project pSys = project "/EMB550_04_Systems"
Module m
for m in current Project do{
if (isEdit m)
print m."Name" "\n"
}*/
for m in pSys do{
if (isEdit m){
setStatus()
updateVariables()
saveObjects()
}
}
/*=====*======*=====*======*======*=====*=====*======*======*======*======*=====*=====*===
////////////////// Main Program //////////////////
*=====*======*=====*======*======*=====*=====*======*======*======*======*=====*=====*===*/
// Start to buid GUI
saveButton = apply(verEvidenceBox, "&Save Module", saveReport)
close(verEvidenceBox, true, closeBox)
// Questions
selectChoiceQC1 = choice(verEvidenceBox, "Q1: ?", options, 1, 13,false)
selectChoiceQC2 = choice(verEvidenceBox, "Q2: ?", options, 1, 13,false)
statusField = field(verEvidenceBox, "Completeness Validation Status", "", 13, true)
textMultiLine = text(verEvidenceBox, "Completeness Validation Comments","", 30, 60, false )
realize verEvidenceBox
updateVariables()
show verEvidenceBox
I would add "Module m" as a parameter to functions "saveObjects()" and also "updateVariables()", and in fact to every other function that deals with a "Module". Change the first two lines of updateVariables() to this, to see what you are doing:
In generaly, avoid global variables as best you can. Common exceptions will be DB and DBE and your main data structures (shared by lots of functions); and stuff that doesn't change like "Module mCurr = current". -Louie |